
cc.Class({
    extends: cc.Component,

    properties: {
        gus: cc.Node,
        carPartical: {
            default: null,
            type: cc.ParticleAsset
        },
    },

    onEnable() {
    },

    onLoad() {

    },

    init(carNode, toRight, color) {
        // console.log("TailGus-init")
        if (color) this.gus.color = color;

        let t = 0.6;
        this.node.active = true;
        let theX = (toRight ? -1 : 1) * (carNode.width / 2 + 10);
        let moveX = toRight ? -40 : 40;

        let self = this;
        iniFunc();
        function iniFunc() {
            self.node.x = theX;
            self.node.y = Math.random() * 50 - 25;
            self.node.scale = 0.5;
        }

        this.node.runAction(cc.repeatForever(
            cc.sequence(
                cc.spawn(
                    cc.scaleTo(t, 0),
                    cc.moveBy(t, moveX, 0)
                ),
                cc.callFunc(iniFunc)
            )
        ));
        carNode.addChild(this.node);
    },

    start() {

    },

    // update (dt) {},
});
